package com.webchat.client.mall.service.im;

import com.webchat.common.bean.APIResponseBean;
import com.webchat.common.bean.APIResponseBeanUtil;
import com.webchat.common.exception.BusinessException;
import com.webchat.domain.vo.response.mall.im.MallChatListItemResponseVO;
import com.webchat.rmi.ugc.mall.im.MallChatAccountClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MallChatAccountService {

    @Autowired
    private MallChatAccountClient mallChatAccountClient;

    public List<MallChatListItemResponseVO> list(String account, String chatAccount, Long lastTime,  int size) {
        APIResponseBean<List<MallChatListItemResponseVO>> response =
                mallChatAccountClient.list(account, chatAccount, lastTime, size);
        if (APIResponseBeanUtil.isOk(response)) {
            return response.getData();
        }
        throw new BusinessException("对话列表加载失败，请稍后重试~");
    }
}
